package judlawei.gui;

import java.awt.Cursor;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Iterator;

import javax.swing.AbstractListModel;
import javax.swing.JList;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

import judlaw.model.bean.docjud.DocumentoJuridico;

import com.sun.xml.internal.bind.v2.schemagen.xmlschema.List;

public class SelecionadorDocumentos extends JList {

    private ArrayList<DocumentoJuridico> docs;
    public SelecionadorDocumentos(ArrayList<DocumentoJuridico> docs) {
        this.docs =  docs;
        inicialzarList();
    }

    private void inicialzarList() {
        this.setModel(new AbstractListModel() {
            String[] strings = apresentarLista();

            public int getSize() {
                return strings.length;
            }

            public Object getElementAt(int i) {
                return strings[i];
            }
        });
        this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        
    }
    
    private String[] apresentarLista(){
        String[] ids = new String[docs.size()];
        int i=0;
        for (DocumentoJuridico documento : docs) {
            ids[i] = documento.getIdentificadorUnico();  
            i++;
        }
        return ids;    
    }
    
    
}
